<html><head><title>Array.pb</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font><font color="#006666">;   PureBasic - Array example file
</font><font color="#006666">;
</font><font color="#006666">;    (c) Fantaisie Software
</font><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font>
<b><font color="#006666">Structure</font></b> BasicStructure 
  Field1.b
  Field2.w
  Field3.l
<b><font color="#006666">EndStructure</font></b>


<b><font color="#006666">Structure</font></b> ComplexStructure
  Field.b
  Basic.BasicStructure <font color="#006666">; Creation of the BasicStructure object inside this structure
</font><b><font color="#006666">EndStructure</font></b>


<b><font color="#006666">Dim</font></b> <font color="#006666">BasicArray</font>.l(100)  <font color="#006666">; Reserve 101 elements from 0 to 100 of 'long' type
</font>
<b><font color="#006666">Dim</font></b> <font color="#006666">StructuredArray</font>.BasicStructure(10) <font color="#006666">; 11 elements from 0 to 10 of 10 BasicStructure objects
</font>
<b><font color="#006666">Dim</font></b> <font color="#006666">StructuredMultiArray</font>.ComplexStructure(10, 20, 10) <font color="#006666">; 11*21*11 = 2541 elements of ComplexStructures objects
</font>
<font color="#006666">; Filling arrays & Structure access
</font><font color="#006666">;
</font><b><font color="#006666">For</font></b> k=0 <b><font color="#006666">To</font></b> 100        <font color="#006666">; Fill the basic array with values from 0 to 100. 
</font><font color="#006666">  BasicArray</font>(k) = k
<b><font color="#006666">Next</font></b>

<b><font color="#006666">For</font></b> k=0 <b><font color="#006666">To</font></b> 10        <font color="#006666">; Fill the structured array..
</font><font color="#006666">  StructuredArray</font>(k)\Field1 = k
<font color="#006666">  StructuredArray</font>(k)\Field2 = k+1
<font color="#006666">  StructuredArray</font>(k)\Field3 = k+2
<b><font color="#006666">Next</font></b>

<b><font color="#006666">For</font></b> x=0 <b><font color="#006666">To</font></b> 10        <font color="#006666">; Fill the multi structured array..
</font>  <b><font color="#006666">For</font></b> y=0 <b><font color="#006666">To</font></b> 20
    <b><font color="#006666">For</font></b> z=0 <b><font color="#006666">To</font></b> 10
<font color="#006666">      StructuredMultiArray</font>(x, y, z)\Field = x
<font color="#006666">      StructuredMultiArray</font>(x, y, z)\Basic\Field2 = y+1
<font color="#006666">      StructuredMultiArray</font>(x, y, z)\Basic\Field3 = z+2
    <b><font color="#006666">Next</font></b>
  <b><font color="#006666">Next</font></b>
<b><font color="#006666">Next</font></b>

<font color="#006666">; Copy the array into a new array
</font><font color="#006666">;
</font><b><font color="#006666">Dim</font></b> <font color="#006666">BasicArrayCopy</font>(1)
<font color="#006666">CopyArray</font>(<font color="#006666">BasicArray</font>(),<font color="#006666"> BasicArrayCopy</font>())

<b><font color="#006666">Debug</font></b> <font color="#006666">ArraySize</font>(<font color="#006666">BasicArrayCopy</font>()) <font color="#006666">; Display the size of the copy, should be 100 as the original
</font>

<b><font color="#006666">End</font></b>
</font></pre>
</body></html>
